import 'package:course_control/app/routes/app_pages.dart';
import 'package:course_control/gen/assets.gen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_utils/flutter_utils.dart';
import 'package:flutter_widgets/flutter_widgets.dart';
import 'package:get/get.dart';

class WifiWidget extends StatefulWidget {
  const WifiWidget({
    super.key,
  });

  @override
  State<WifiWidget> createState() => _WifiWidgetState();
}

class _WifiWidgetState extends State<WifiWidget> {
  void onPressed(String title) {
    LogUtil.logI(title);
    switch (title) {
      case '终端':
        break;
      case '教师机':
        break;
      case '网络':
        break;
      case '设置':
        Get.toNamed(Routes.SETTING);
        break;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        _buildWifiItem('终端'),
        SizedBox(
          width: 16.ratio,
        ),
        _buildWifiItem('教师机'),
        SizedBox(
          width: 16.ratio,
        ),
        _buildWifiItem('网络'),
        SizedBox(
          width: 16.ratio,
        ),
        InkWell(
          onTap: () => onPressed('设置'),
          child: CommonImage.asset(Assets.images.iconSetting.path,
              width: 30.ratio),
        ),
      ],
    );
  }

  Widget _buildWifiItem(String title) {
    return InkWell(
      onTap: () => onPressed(title),
      child: Container(
        width: 120.ratio,
        height: 36.ratio,
        decoration: BoxDecoration(
          color: Colors.white.withOpacity(0.1),
          borderRadius: BorderRadius.circular(18.ratio),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            CommonImage.asset(
              Assets.images.iconWifi.path,
              width: 16.ratio,
            ),
            Text(
              title,
              style: TextStyle(
                  fontSize: 20.ratio, color: Colors.white.withOpacity(0.5)),
            )
          ],
        ),
      ),
    );
  }
}
